package com.numkit.briefdraw.store;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class CommonFileFilter extends FileFilter {

	private String ext = null;

	private String description = null;

	public CommonFileFilter(String ext, String description) {
		this.ext = ext;
		this.description = description;
	}

	public boolean accept(File file) {
		if (file.isDirectory())
			return true;
		String fileFullName = file.getAbsolutePath().toLowerCase();
		if (fileFullName.endsWith(ext))
			return true;
		return false;
	}

	public String getDescription() {
		return "(*" + ext + ") " + description;
	}

}
